<%@page import="entity.ProductAvailability"%>
<%@include file="/header.jsp" %>


<div id="breadcrump">
    <ul id="breadcrump-list">
        <li>&raquo; Product wijzigen</li>
    </ul>
</div>

<c:choose>
    <c:when test="${param.success == 'true'}">
        <c:url value="/backend/ProductAdmin" var="backUrl">
            <c:param name="category_id" value="${param.category_id}" />
        </c:url>
        Product is gewijzigd! <a href="${backUrl}">Terug</a>
    </c:when>
    <c:when test="${product == null}">
        Product niet gevonden.
    </c:when>
    <c:when test="${product != null}">
        <c:url value="/backend/ProductAdmin" var="backUrl">
            <c:param name="category_id" value="${product.category.id}" />
        </c:url>
        
        <form action="" method="POST">
            <table border="1">
                <tr>
                    <td><label for="txtName">Naam</label></td>
                    <td><input type="text" name="name" value="${fn:escapeXml(product.name)}" id="txtName"></td>
                </tr>
                <tr>
                    <td><label for="txtName">Categorie</label></td>
                    <td>
                        <select name="categoryId">
                            <c:forEach var="category" items="${categories}">
                                <option value="${category.id}" ${product.category.id == category.id ? "selected=\"selected\"" : ""}>
                                    ${fn:escapeXml(category.name)}
                                </option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label for="txtName">Beschikbaarheid</label></td>
                    <td>
                        <c:set var="enumValues" value="<%=ProductAvailability.values()%>"/>
                        <select name="availability">
                            <c:forEach var="availability" items="${enumValues}">
                                <option value="${availability.ordinal()}" ${availability.ordinal() == product.availability.ordinal() ? "selected=\"selected\"" : ""}>
                                    ${fn:escapeXml(availability)}
                                </option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td><label for="txtPrice">Prijs</label></td>
                    <td>
                        <input value="${fn:escapeXml(product.price)}" type="text" name="price" id="txtPrice">
                    </td>
                </tr>
                <tr>
                    <td><label for="txtDesc">Omschrijving</label></td>
                    <td>
                        <textarea name="description" id="txtDesc" rows="17" cols="45">${fn:escapeXml(product.description)}</textarea>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="submit" value="Opslaan"></td>
                </tr>
            </table>
        </form>
        <a href="${backUrl}">Terug</a>
    </c:when>
</c:choose>

<%@include file="/footer.jsp" %>
